import React from 'react';
import { Route, Switch, Router } from 'dva/router';
import routers from './routes/main';
import dynamic from 'dva/dynamic';

function RouterConfig({ history, app }) {
  return (
      <Router history={history}>
        <Switch>
          {
            routers.map(({ path, name, ...dynamics }) => <Route key={name} path={path} exact component={dynamic({ app, ...dynamics })}/>)
          }
        </Switch>
      </Router>
  );
}

export default RouterConfig;
